// 导入 jsonwebtoken 模块
const jwt = require("jsonwebtoken");

// 生成 token
let token = jwt.sign(
  {
    username: "pipi",
  },
  "techfengs",
  {
    expiresIn: 60 * 3,
  },
);
console.log(token);

// 校验token
let t =
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InBpcGkiLCJpYXQiOjE3MTMxODMzMzUsImV4cCI6MTcxMzE4MzUxNX0.A2uD54rYQtJtRr0GpqYVzaAIPT9gdNYgIByEdcP9Wj4";
jwt.verify(t, "techfengs", (err, data) => {
  if (err) {
    console.log(err);
    return;
  }
  console.log(data);
});
